package com.yoj.judgeservice.feign;

import com.yoj.judgeservice.service.JudgeService;
import com.yoj.model.entity.QuestionSubmit;
import com.yoj.serviceclient.service.judge.JudgeFeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 判题服务内部接口：仅内部调用接口，不是给前端的
 */
@RestController()
@RequestMapping("/inner")
public class JudgeClient implements JudgeFeignClient {

    @Resource
    private JudgeService judgeService;

    /**
     * 判题
     * @param questionSubmitId 题目提交id
     * @return 题目提交信息的判题结果
     */
    @Override
    @PostMapping("/do")
    public QuestionSubmit doJudge(@RequestParam("questionSubmitId") long questionSubmitId) {
        return judgeService.doJudge(questionSubmitId);
    }
}
